# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This class is auto generated by the swagger code generator program.
# https://github.com/swagger-api/swagger-codegen.git
# Do not edit the class manually.

defmodule GoogleApi.ReplicaPool.V1beta2.Model.Operation do
  @moduledoc """
  An operation resource, used to manage asynchronous API requests.

  ## Attributes

  - clientOperationId (String): [Output only] An optional identifier specified by the client when the mutation was initiated. Must be unique for all operation resources in the project. Defaults to: `null`.
  - creationTimestamp (String): [Output Only] The time that this operation was requested, in RFC3339 text format. Defaults to: `null`.
  - endTime (String): [Output Only] The time that this operation was completed, in RFC3339 text format. Defaults to: `null`.
  - error (OperationError):  Defaults to: `null`.
  - httpErrorMessage (String): [Output only] If operation fails, the HTTP error message returned. Defaults to: `null`.
  - httpErrorStatusCode (Integer): [Output only] If operation fails, the HTTP error status code returned. Defaults to: `null`.
  - id (String): [Output Only] Unique identifier for the resource, generated by the server. Defaults to: `null`.
  - insertTime (String): [Output Only] The time that this operation was requested, in RFC3339 text format. Defaults to: `null`.
  - kind (String): [Output only] Type of the resource. Defaults to: `null`.
  - name (String): [Output Only] Name of the resource. Defaults to: `null`.
  - operationType (String): [Output only] Type of the operation. Operations include insert, update, and delete. Defaults to: `null`.
  - progress (Integer): [Output only] An optional progress indicator that ranges from 0 to 100. There is no requirement that this be linear or support any granularity of operations. This should not be used to guess at when the operation will be complete. This number should be monotonically increasing as the operation progresses. Defaults to: `null`.
  - region (String): [Output Only] URL of the region where the operation resides. Only available when performing regional operations. Defaults to: `null`.
  - selfLink (String): [Output Only] Server-defined fully-qualified URL for this resource. Defaults to: `null`.
  - startTime (String): [Output Only] The time that this operation was started by the server, in RFC3339 text format. Defaults to: `null`.
  - status (String): [Output Only] Status of the operation. Defaults to: `null`.
    - Enum - one of [DONE, PENDING, RUNNING]
  - statusMessage (String): [Output Only] An optional textual description of the current status of the operation. Defaults to: `null`.
  - targetId (String): [Output Only] Unique target ID which identifies a particular incarnation of the target. Defaults to: `null`.
  - targetLink (String): [Output only] URL of the resource the operation is mutating. Defaults to: `null`.
  - user (String): [Output Only] User who requested the operation, for example: user@example.com. Defaults to: `null`.
  - warnings (List[OperationWarnings]): [Output Only] If there are issues with this operation, a warning is returned. Defaults to: `null`.
  - zone (String): [Output Only] URL of the zone where the operation resides. Only available when performing per-zone operations. Defaults to: `null`.
  """

  defstruct [
    :clientOperationId,
    :creationTimestamp,
    :endTime,
    :error,
    :httpErrorMessage,
    :httpErrorStatusCode,
    :id,
    :insertTime,
    :kind,
    :name,
    :operationType,
    :progress,
    :region,
    :selfLink,
    :startTime,
    :status,
    :statusMessage,
    :targetId,
    :targetLink,
    :user,
    :warnings,
    :zone
  ]
end

defimpl Poison.Decoder, for: GoogleApi.ReplicaPool.V1beta2.Model.Operation do
  import GoogleApi.ReplicaPool.V1beta2.Deserializer

  def decode(value, options) do
    value
    |> deserialize(:error, :struct, GoogleApi.ReplicaPool.V1beta2.Model.OperationError, options)
    |> deserialize(
      :warnings,
      :list,
      GoogleApi.ReplicaPool.V1beta2.Model.OperationWarnings,
      options
    )
  end
end

defimpl Poison.Encoder, for: GoogleApi.ReplicaPool.V1beta2.Model.Operation do
  def encode(value, options) do
    GoogleApi.ReplicaPool.V1beta2.Deserializer.serialize_non_nil(value, options)
  end
end
